package com.YCH.article.controller.v1;


import com.YCH.apis.app.apis.AppInformatonApi;
import com.YCH.apis.article.apis.ArticleHomeControllerApi;
import com.YCH.article.service.AppArticleService;
import com.YCH.article.service.AppInformationService;
import com.YCH.common.article.constans.ArticleConstans;
import com.YCH.model.article.dtos.AppRealTimeInfoDto;
import com.YCH.model.article.dtos.AppRecommendTopicDto;
import com.YCH.model.article.dtos.ArticleHomeDto;
import com.YCH.model.article.vos.AppRealTimeInfoId;
import com.YCH.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController implements ArticleHomeControllerApi, AppInformatonApi {
    @Autowired
    private AppArticleService appArticleService;

    @Autowired
    private AppInformationService appInformationService;

    @Override
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return appArticleService.load(dto, ArticleConstans.LOADTYPE_LOAD_MORE);
    }

    @Override
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return appArticleService.load(dto, ArticleConstans.LOADTYPE_LOAD_MORE);
    }

    @Override
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return appArticleService.load(dto, ArticleConstans.LOADTYPE_LOAD_NEW);
    }

    @Override
    @GetMapping("/real_time_info")
    public ResponseResult realTimeInfo(AppRealTimeInfoDto dto) {
        List<AppRealTimeInfoId> result = new ArrayList<>();
        AppRealTimeInfoId appRealTimeInfoId1 = new AppRealTimeInfoId();
        appRealTimeInfoId1.setFlagId(7);
        AppRealTimeInfoId appRealTimeInfoId2 = new AppRealTimeInfoId();
        appRealTimeInfoId2.setFlagId(8);
        AppRealTimeInfoId appRealTimeInfoId3 = new AppRealTimeInfoId();
        appRealTimeInfoId3.setFlagId(9);
        result.add(appRealTimeInfoId1);
        result.add(appRealTimeInfoId2);
        result.add(appRealTimeInfoId3);
        return appInformationService.loadRealTimeInfo(result);
    }

    @Override
    @GetMapping("/recommend_topics")
    public ResponseResult recommendedTopics(AppRecommendTopicDto dto) {
        return appInformationService.loadRecommendTopic(dto);
    }

    @Override
    @GetMapping("/all_topics")
    public ResponseResult loadAllTopics(){
        return appInformationService.loadAllTopics();
    }

    @Override
    @GetMapping("/month_hot")
    public ResponseResult loadMonthHot() {
        return appInformationService.loadMonthlyHotList();
    }

    @Override
    @GetMapping("/recommend_users")
    public ResponseResult loadRecommend() {
        return appInformationService.loadRecommendUsers();
    }
}
